<?php


namespace api\zmt\controller;


use api\zmt\model\goodsModel;
use cmf\controller\RestBaseController;

class Goodsinfomation extends RestBaseController
{
    public function index(){
        $list = goodsModel::select();
        $this->success('商品显示',$list);
    }
    //查看商品详情
    public function getGoodsInfo(){
        $goods_id = input('spu_id/d');
        $goods = goodsModel::where('id',$goods_id)->find();
        unset($goods['info']);
        $goodsAttr = json_decode($goods['attr'],true);
        foreach ($goodsAttr as $key => $val){
            $goodsAttr[$key]['attr_value'] = explode(',',$val['attr_value']);
        }
        $goods['attr'] = $goodsAttr;
        $this->success('商品详情',$goods);
    }
}